import requests from './request'
import mockRequests from './mockRequest'

//三级联动接口
// /api/product/getBaseCategoryList GET 
export const reqCategoryList = () => requests({
    url: '/product/getBaseCategoryList',
    method: 'get'
});

//获取banner轮播图接口
export const reqBannerList = () => mockRequests.get('/banner')

//获取floor轮播图接口
export const reqFloorList = () => mockRequests.get('/floor')

//搜索商品
// /api/list POST category1Id/category2Id/category3Id/categoryName/keyword/props/trademark/order/pageNo/pageSize
export const resSearchInfo = (params) => requests({
    url: '/list',
    method: 'post',
    data: params //params参至少是一个空对象
})

//获取商品详情
// /api/item/{ skuId } GET
export const reqGoodsInfo = (skuId) => requests({
    url: `/item/${skuId}`,
    method: 'get'
})

//获取购物车列表
// /api/cart/cartList GET
export const reqCartList = () => requests({
    url: '/cart/cartList',
    method: 'get'
})

//添加购物车
// /api/cart/addToCart/{ skuId }/{ skuNum } POST
export const resAddOrUpdateShopCar = (skuId, skuNum) => requests({
    url: `/cart/addToCart/${skuId}/${skuNum}`,
    method: 'post'
})

//切换商品选中状态
// /api/cart/checkCart/{skuID}/{isChecked} GET
export const reqChangeChecked = (skuId, isChecked) => requests({
    url: `/cart/checkCart/${skuId}/${isChecked}`,
    method: 'get'
})

//删除购物车商品
// /api/cart/deleteCart/{skuId} DELETE
export const resDeleteCart = (skuId) => requests({
    url: `/cart/deleteCart/${skuId}`,
    method: 'delete'
})

//登录
// /api/user/passport/login POST {phone}/{password}
export const resLogin = (data) => requests({
    url: '/user/passport/login',
    data,
    method: 'post'
})

//通过token校验获取用户登录信息
// /api/user/passport/auth/getUserInfo get
export const reqUserInfo = () => requests({
    url: '/user/passport/auth/getUserInfo',
    method: 'get'
})

//退出登录
// /api/user/passport/logout GET
export const reqLogout = () => requests({
    url: '/user/passport/logout',
    method: 'get'
})

//自动登录
// /api/user/passport/auth/getUserInfo GET

//注册用户
// /api/user/passport/register POST {phone}/{password}/{code}/nickName
export const resRegister = (data) => requests({
    url: '/user/passport/register',
    data,
    method: 'post'
})

//获取注册验证码
// /api/user/passport/sendCode/phone GET {phone}
export const reqSendCode = (phone) => requests({
    url: `/user/passport/sendCode/${phone}`,
    method: 'get'
})

//获取用户地址信息
// /api/user/userAddress/auth/findUserAddressList get
export const reqUserAddress = () => requests({
    url: '/user/userAddress/auth/findUserAddressList',
    method: 'get'
})

//获取订单交易信息
// /api/order/auth/trade GET
export const reqOrder = () => requests({
    url: '/order/auth/trade',
    method: 'get'
})

//提交订单
// /api/order/auth/submitOrder?tradeNo={tradeNo} POST {traderNo}/{consignee}/{consigneeTel}/{deliveryAddress}/{paymentWay}/{orderComment}/{orderDetailList}
export const resSubmitOrder = (tradeNo, data) => requests({
    url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
    data,
    method: 'post'
})


//获取订单支付信息
// /api/payment/weixin/createNative/{orderId} GET
export const reqPayInfo = (orderId) => requests({
    url: `/payment/weixin/createNative/${orderId}`,
    method: 'get'
})

//查询支付订单状态
// /api/payment/weixin/queryPayStatus/{orderId} GET
export const reqPayState = (orderId) => requests({
    url: `/payment/weixin/queryPayStatus/${orderId}`,
    method: 'get'
})

//获取我的订单列表
// /api/order/auth/{page}/{limit} GET
export const reqOrderList = (page, limit) => requests({
    url: `/order/auth/${page}/${limit}`,
    method: 'get'
})